<template>
  <ul class="list">
    <li v-for="item in arr" :key="item.id" @click="details(item.id)">
      <section>
        <img :src="imgBaseUrl + item.coverImg" alt="" />
        <div class="botton-box">
          <h3>{{ item.name }}</h3>
          <p>{{ item.coin }}积分</p>
          <div class="btn">立即兑换</div>
        </div>
        <div class="flag">
          <img
            v-show="item.isHotSale == 1"
            src="../../assets/img/section_hot.png"
            alt=""
          />
          <img
            v-show="item.isLatest == 1"
            src="../../assets/img/section_new.png"
            alt=""
          />
        </div>
      </section>
    </li>
  </ul>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: ["arr"],
  methods: {
    details(id) {
      // 点击去详情页把商品id传递过去

      // 第一种
      this.$router.push("./details?id=" + id);
      // 第二种
      // this.$router.push({ path: `details`, query: { id: id } });
      // 第三种
      // this.$router.push({ name: `Details`, query: { id: id } });
    },
  },
};
</script>
 
<style lang = "less" scoped>
.list {
  /* overflow: hidden; */
  display: flex;

  /* justify-content: space-between; */
  /* 自动换行 */
  flex-wrap: wrap;
  width: 1220px;

  li {
    width: 285px;
    /* margin: 20px; */
    margin-right: 20px;
    margin-top: 20px;

    .botton-box {
      width: 285px;
      height: 162px;
      background-color: #fff;
      text-align: center;

      h3 {
        font-size: 18px;
        font-family: SourceHanSansSC;
        font-weight: 300;
        color: #333333;
        height: 56px;
        line-height: 56px;
      }
      p {
        font-size: 18px;
        font-family: SourceHanSansSC;
        font-weight: bold;
        color: #fd604d;
      }
      .btn {
        width: 100px;
        height: 36px;
        line-height: 36px;
        border: 1px solid #0a328e;
        margin: 0 auto;
        margin-top: 20px;
      }
    }
    section {
      position: relative;
      width: 285px;
      height: 492px;
      transition: all 0.5s linear;

      .flag {
        position: absolute;
        left: 0;
        top: 0;
      }
    }
    &:hover {
      cursor: pointer;
      section {
        transform: translateY(-15px);
        box-shadow: 0 0 10px #ccc;
        .btn {
          background: #0a328e;
          color: #fff;
        }
      }
    }
  }
}
</style>